-- When will this be over? -- Simple extension which displays the time when the current media will be finished playing -- Extension description function descriptor() return { title = "Finish Time" ; version = "1.0" ; author = "Rajesh Verma" ; url = 'http://www.rawdust.com/'; shortdesc = "Displays the time when the current media will be finished playing"; description = "Displays the time when the current media will be finished playing" ; capabilities = { } } end -- Activation hook function activate() -- get elapsed time in seconds local input = vlc.object.input() local current = vlc.var.get(input, "time") -- get duration in seconds local duration = vlc.input.item():duration() -- calculate hour, minute, second values for remaining time local remaining = duration - current -- get system seconds, minutes, hours local systemHour = os.date("%I") local systemMinute = os.date("%M") local systemSecond = os.date("%S") -- show the result on the on-screen display (OSD) local outputString = " " for i=0,10 do remainingi = remaining/(1+i/10) local remainingHour = math.floor(remainingi / 3600) local remainingMinute = math.floor((remainingi % 3600) / 60) local remainingSecond = math.floor(remainingi % 60) -- add the two together, carrying as needed local endingSecond = math.floor((systemSecond + remainingSecond) % 60) local endingMinute = math.floor(((systemSecond + remainingSecond) / 60 + (systemMinute + remainingMinute)) % 60) local endingHour = math.floor((((systemSecond + remainingSecond) / 60 + (systemMinute + remainingMinute)) / 60 + systemHour + remainingHour) % 12) if (endingHour==0) then endingHour=12 end --saved saved= remaining - remainingi local savedHour = math.floor(saved / 3600) local savedMinute = math.floor((saved % 3600) / 60) local savedSecond = math.floor(saved % 60) outputString = outputString..string.format("%2d:%02d:%02d %d:%02d:%02d (%d:%02d:%02d) %.1fx".."\n", endingHour, endingMinute, endingSecond,remainingHour,remainingMinute,remainingSecond,savedHour,savedMinute,savedSecond,1+i/10) if i==4 or i==5 then outputString = outputString .."\n" end end vlc.osd.message(outputString,channel1,top,10000000) -- below undefined function will cause extension to die. -- (and thus automatically uncheck it from view menu) -- I'm using this UGLY hack because the obvious call to deactivate() doesn't work fail() end -- Deactivation hook function deactivate() end